package com.asset.common.enums;


import com.asset.common.exception.IMessageCode;
import com.asset.common.utils.PropertiesUtil;

/**
 * @author luoyongzhi
 */

@SuppressWarnings("all")
public enum SystemEnum implements IMessageCode {

    UNKNOWN("-1", "系统错误，请稍后再试！"),

    OK("0", "OK"),

    TIMEOUT("1", "服务超时"),

    VALIDATE("2", "参数校验失败"),

    INVALID("3", "无效的通讯数据"),

    MISS_CURRENTUSERID("4", "缺少当前访问者id"),

    MISS_CLIENTIDS("5", "缺少客户端id"),

    Auth("6", "鉴权失败"),

    API_NOTEXIST("7", "接口不存在"),

    DATABASE_OPERATION_FAILED("8", "数据库操作失败"),

    IP_NOT_VALID("9", "RPC请求IP不合法"),

    LACK_REQUIRED_FIELD("10", "缺少必填字段"),

    PARAMETER_EXCEPTION("11", "参数异常"),

    // 客户端限流
    SERVICE_SHORTCIRCUIT("12", "服务熔断"),

    SERVICE_TIMEOUT("13", "服务超时"),

    SERVICE_REJECTED("14", "服务限流"),

    SERVICE_FALLBACK_FAIL("15", "服务降级逻辑执行失败"),
    // 客户端限流

    SERVICE_UNAVAILABLE("16", "服务不可用"),

    SERVICE_INITIAL_END("17", "服务调用方已停止"),

    APP_DECRYPT_FAILED("18", "app请求解密失败"),

    // 服务端限流
    SERVICE_LIMIT("19", "服务端接口限流"),

    SERVICE_LIMIT_FALLBACK_FAIL("20", "服务端接口限流之降级逻辑执行失败"),

    INVALID_CURRENTUSERID("21", "当前访问者id不是数字类型");

    private String code;
    private String desc;

    private SystemEnum(String code, String desc) {
        this.code = code;
        this.desc = PropertiesUtil.get("MessageCode." + this.name(), desc);
    }

    @Override
    public String code() {
        return code;
    }

    @Override
    public String message() {
        return desc;
    }

    @Override
    public String toString() {
        return name();
    }

}

